package jp.co.hcs.attendancemanagement.inputtableb.logic;

import java.sql.SQLException;

import jp.co.hcs.attendancemanagement.data.dao.WorkDAO;
import jp.co.hcs.attendancemanagement.data.entity.Work;
import jp.co.hcs.attendancemanagement.logic.LogicBase;

/**
 * The Class CheckWorkCodeLogic.
 */
public class CheckWorkCodeLogic extends LogicBase {

  /** The check work code logic. */
  private static CheckWorkCodeLogic checkWorkCodeLogic = new CheckWorkCodeLogic();

  /** The work dao. */
  private WorkDAO workDAO;

  /**
   * Gets the single instance of CheckWorkCodeLogic.
   * 
   * @return single instance of CheckWorkCodeLogic
   */
  public static CheckWorkCodeLogic getInstance() {
    return checkWorkCodeLogic;
  }

  /**
   * Check work code existing.
   * 
   * @param inputWorkCode the input work code
   * @return the work
   * @throws SQLException the sQL exception
   */
  public Work checkWorkCodeExisting(String inputWorkCode) throws SQLException {
    Work work = getWorkDAO().selectWorkByPrimaryKey(inputWorkCode);
    return work;
  }

  /**
   * Gets the work dao.
   * 
   * @return the work dao
   */
  public WorkDAO getWorkDAO() {
    if (workDAO == null) {
      workDAO = daoFactory.getWorkDAO();
    }

    return workDAO;
  }

  /**
   * Sets the work dao.
   * 
   * @param workDAO the new work dao
   */
  public void setWorkDAO(WorkDAO workDAO) {
    this.workDAO = workDAO;
  }

}
